<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1></h1>
    <script>
        const a = {
            num: 1,
            hobbit: ['学习', '看视频', '敲代码'],
            student: {
                uname: '杨桑',
                age: '18',
                hobbit: ['打篮球', '学习', '看视频', '敲代码'],
            },
            x: undefined,
        }
        function clone(old) {
            let b
            if (old instanceof Array) {
                b = []
                for (let i = 0; i < old.length; i++) {
                    b[i] = clone(old[i])
                }
            }
            else if (old instanceof Object) {
                b = {}
                for (let key in old) {
                    b[key] = clone(old[key])
                }
            }
            else {
                b = old
            }
            return b
        }
        b = clone(a)
        console.log(b)

    </script>
</body>

</html>